package com.yanfan.parking.controller;

import java.util.Arrays;
import java.util.List;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.parking.domain.NjOutParkingRecord;
import com.yanfan.parking.service.INjOutParkingRecordService;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.common.core.page.TableDataInfo;

/**
 * 停车场出场记录Controller
 *
 * @author genluo
 * @date 2024-10-28
 */
@Api(tags = "停车场出场记录")
@RestController
@RequestMapping("/parking/outRecord")
public class NjOutParkingRecordController extends BaseController {
    @Autowired
    private INjOutParkingRecordService njOutParkingRecordService;

    /**
     * 查询停车场出场记录列表
     */
    @ApiOperation("停车场出场记录分页列表")
    @PreAuthorize("@ss.hasPermi('parking:outRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjOutParkingRecord njOutParkingRecord) {
        startPage();
        List<NjOutParkingRecord> list = njOutParkingRecordService.queryPageList(njOutParkingRecord);
        return getDataTable(list);
    }

    /**
     * 导出停车场出场记录列表
     */
    @ApiOperation("导出停车场出场记录列表")
    @PreAuthorize("@ss.hasPermi('parking:outRecord:export')")
    @Log(title = "停车场出场记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjOutParkingRecord njOutParkingRecord) {
        List<NjOutParkingRecord> list = njOutParkingRecordService.queryPageList(njOutParkingRecord);
        ExcelUtil<NjOutParkingRecord> util = new ExcelUtil<NjOutParkingRecord>(NjOutParkingRecord.class);
        util.exportExcel(response, list, "停车场出场记录数据");
    }

    /**
     * 获取停车场出场记录详细信息
     */
    @ApiOperation("获取停车场出场记录详细信息")
    @PreAuthorize("@ss.hasPermi('parking:outRecord:query')")
    @GetMapping(value = "/{bizSn}")
    public AjaxResult getInfo(@PathVariable("bizSn") String bizSn) {
        return success(njOutParkingRecordService.getById(bizSn));
    }

    /**
     * 新增停车场出场记录
     */
    @ApiOperation("新增停车场出场记录")
    @PreAuthorize("@ss.hasPermi('parking:outRecord:add')")
    @Log(title = "停车场出场记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody NjOutParkingRecord njOutParkingRecord) {
        return toAjax(njOutParkingRecordService.save(njOutParkingRecord));
    }

    /**
     * 修改停车场出场记录
     */
    @ApiOperation("修改停车场出场记录")
    @PreAuthorize("@ss.hasPermi('parking:outRecord:edit')")
    @Log(title = "停车场出场记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody NjOutParkingRecord njOutParkingRecord) {
        return toAjax(njOutParkingRecordService.updateById(njOutParkingRecord));
    }

    /**
     * 删除停车场出场记录
     */
    @ApiOperation("删除停车场出场记录")
    @PreAuthorize("@ss.hasPermi('parking:outRecord:remove')")
    @Log(title = "停车场出场记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{bizSns}")
    public AjaxResult remove(@PathVariable String[] bizSns) {
        return toAjax(njOutParkingRecordService.removeBatchByIds(Arrays.asList(bizSns)));
    }
}
